<?php
/**
 * Created by PhpStorm.
 * User: River
 * Email: river0428@gmail.com
 * Date: 2018/6/11
 * Time: 上午11:03
 */
namespace Modules\Admin\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Route;
use Modules\Admin\Auth\AdminAuth;

class AdminServiceProvider extends ServiceProvider
{
    //protected $defer = true;

    /**
     * Bootstrap services.
     *
     * @return void
     */
    public function boot()
    {
        $this->loadViews();
        $this->loadRoutes();
    }

    /**
     * Register services.
     *
     * @return void
     */
    public function register()
    {
        $this->app->singleton('admin_auth', function () {
            return new AdminAuth();
        });
    }

    public function loadViews()
    {
        $this->loadViewsFrom(module_path('Admin/Auth/views'), 'admin.auth');
        $this->loadViewsFrom(module_path('Admin/Main/views'), 'main');
    }

    public function loadRoutes()
    {
        Route::namespace('Modules\Admin\Auth\Controllers')
            ->middleware('web')
            ->group(module_path('Admin/Auth/routes/web.php'));

        Route::namespace('Modules\Admin\Main\Controllers')
            ->middleware('web')
            ->group(module_path('Admin/Main/routes/web.php'));
    }

    /**
     * Get the services provided by the provider.
     *
     * @return array
     */
    public function provides()
    {
        return [];
    }
}